package com.company;

import java.util.Scanner;

public class Student extends Teacher{
    String grade;
    public Student(int number,String name,String gender,String course,int course1,String grade){
        super(number,name,gender,course,course1);
        this.grade=grade;
    }
    public void choice(Student a1,Student b1,Course a2,Course b2){
        System.out.println("按1为学生小明选课，按2为学生小红选课,按其他数字返回：");
        Scanner input1=new Scanner(System.in);
        int c1=input1.nextInt();
        if(c1==1){
            System.out.println("按1为选数学，按2为选英语：");
            Scanner input2=new Scanner(System.in);
            int c2=input2.nextInt();
            if(c2==1&& a1.course1==0 && a2.teacher1!=0){
                a1.course=a2.name;
                a1.course1=1;
                a2.people=a2.people+1;
                System.out.println("选课成功");
            }
            if(c2==2&& a1.course1==0 && b2.teacher1!=0){
                a1.course=b2.name;
                a1.course1=2;
                b2.people=b2.people+1;
                System.out.println("选课成功");
            }
        }
        if(c1==2){
            System.out.println("按1为选数学，按2为选英语：");
            Scanner input2=new Scanner(System.in);
            int c2=input2.nextInt();
            if(c2==1 && b1.course1==0 && a2.teacher1!=0){
                b1.course=a2.name;
                b1.course1=1;
                a2.people=a2.people+1;
                System.out.println("选课成功");
            }
            if(c2==2 &&b1.course1==0 && b2.teacher1!=0){
                b1.course=b2.name;
                b1.course1=2;
                b2.people=b2.people+1;
                System.out.println("选课成功");
            }
        }
    }
    public void nochoice(Student a1,Student b1,Course a2,Course b2){
        System.out.println("按1为学生小明退课，按2为学生小红退课,按其他数字返回：");
        Scanner input1=new Scanner(System.in);
        int c1=input1.nextInt();
        if(c1==1){
            System.out.println("按1为退数学，按2为退英语：");
            Scanner input2=new Scanner(System.in);
            int c2=input2.nextInt();
            if(c2==1&&a1.course1!=0){
                a1.course="nothing";
                a1.course1=0;
                a2.people=a2.people-1;
                System.out.println("退课成功");
            }
            if(c2==2 && a1.course1!=0){
                a1.course="nothing";
                a1.course1=0;
                b2.people=b2.people-1;
                System.out.println("退课成功");
            }
        }
        if(c1==2){
            System.out.println("按1为退数学，按2为退英语：");
            Scanner input2=new Scanner(System.in);
            int c2=input2.nextInt();
            if(c2==1 && b1.course1!=0 ){
                b1.course="nothing";
                b1.course1=0;
                a2.people=a2.people-1;
                System.out.println("退课成功");
            }
            if(c2==2 && b1.course1!=0){
                b1.course="nothing";
                b1.course1=0;
                b2.people=b2.people-1;
                System.out.println("退课成功");
            }
        }
    }
    public String toString(){
        return "学号:"+number+"\n"+"姓名："+name+"\n"+"年级："+grade+"\n";
    }
}
